<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="carPackageList">
      <el-table-column label="套餐名称" align="center" prop="serviceItemName" />
      <el-table-column label="套餐价格" align="center" prop="serviceItemPrice" />
      <el-table-column label="服务单项备注" align="center" prop="serviceItemInfo" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.aud_car_package_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-thumb"
            @click="handleAudit(scope.row)"
            v-hasPermi="['audit:carPackage:remove']"
          >审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 套餐审核对话框 -->
    <el-dialog title="套餐审核" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form"  label-width="80px">
        <el-form-item label="结果" prop="status">
          <el-select v-model="form.status" placeholder="请选择状态">
            <el-option
              v-for="dict in result"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item  label="备注" prop="info">
          <el-input type="textarea" v-model="form.info" placeholder="请输入备注" />
        </el-form-item>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listToDoCarPackage,auditAuditServiceItem} from "@/api/audit/carPackage";

export default {
  name: "CarPackage",
  dicts: ['aud_car_package_status'],
  data() {
    return {
      // 对话框控制变量
      open: false,
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 套餐审核表格数据
      carPackageList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        
      },
      
      form:{
        info:null,
        status:null,
      },
      // 结果
      result:[
        {label:"拒绝",value:0},
        {label:"通过",value:1}
      ]
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 打开审核对话框
    handleAudit(row) {
      
      
      this.form={};
      this.form.processInstanceId = row.instanceId;
      this.open = true;
      // 不使用bus_car_package
      /* this.form={};
      this.form.serivceId = row.id;
      this.open = true; */
    },
    // 审核
    submitForm() {
        // 流程实例id
        // 拒绝还是通过
        // 备注
        console.log(this.form);

        auditAuditServiceItem(this.form).then(res => {
          
          console.log(res);
          this.open = false;
          this.$modal.msgSuccess("操作成功");
          this.getList();
        });


         
        /* 
        服务项id
        拒绝还是通过
        备注
        console.log(this.form);

        auditAuditServiceItem(this.form).then(res => {
          
          console.log(res);
          this.open = false;
          this.$modal.msgSuccess("操作成功");
          this.getList();
        }); */
    },
    /** 查询待办套餐审核列表 */
    getList() {
      this.loading = true;
      listToDoCarPackage(this.queryParams).then(response => {
        this.carPackageList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
   }
  };
</script>
